#include "../source/TcpServer.hpp"


void OnConnextDis(const Ptrconnection &con)
{
	DEL_LOG("close connection : %p", con->GetContext());
}
void OnConnect(const Ptrconnection &con)
{
	DEL_LOG("new connection : %p", con->GetContext());
}

void OnMessage(const Ptrconnection &con, Buffer *buff)
{
	DEL_LOG("%s", buff->ReadPosition());
	buff->MoveReadOffset(buff->ReadableSize());
	std::string str = "hell bit";
	con->Send(str.c_str(), str.size());
}

int main()
{
	TcpServer tcp(8080);
	tcp.SetThreadCount(2);
	// tcp.EnableInactiveRelease(10);
	tcp.SetMessageCallback(OnMessage);
	tcp.SetCloseCallback(OnConnextDis);
	tcp.SetConnectCallback(OnConnect);
	tcp.Start();
}